home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / gfx / edit / AmiCAD_2.07.lha / AmiCAD / ARexx / grille.AmiCAD < prev    next >
Text File  |  2000-11-09  |  5KB  |  206 lines

  1. /* Création d'une grille quadrillée
  2. $VER: Grille.AmiCAD 1.06 (© R.Florac, 9/11/2000)
  3. Version 1.00 ©R.Florac, Mardi 3 Mars 1998
  4. Version 1.01, 25 avril 1998 (utilisation d'un rectangle pour définir la zone recevant la grille)
  5. Version 1.02, 12 novembre 1998 (correction bug variables x0 et y0)
  6. Version 1.03, 29 Mars 1999 (ajout GETZONE)
  7. Version 1.04, 22 Mai 1999 (Modification DRAWMODE)
  8. Version 1.05, 13 avril 2000 (Adaptation version 2.05)
  9. Version 1.06, 9 novembre 2000 (Localisation anglais/français) */
  10.  
  11. options results     /* indispensable pour récupérer le résultat des macros */
  12.  
  13. signal on error     /* pour l'interception des erreurs */
  14. signal on syntax
  15.  
  16. 'LANGUAGE'
  17. if result="français.language" then fr=1
  18. else fr=0
  19.  
  20. 'WWIDTH'; lt = result
  21. 'WHEIGHT'; ht=result
  22. clip=-1
  23. FIRSTSEL; obj=result
  24. if obj>0 then do
  25.     'TYPE(FIRSTSEL)'; type=result
  26.     if type=22 then do
  27.     'CLIPUNIT(5)'; clip=result
  28.     'COORDS(FIRSTSEL)'; coords=result
  29.     PARSE VAR coords x0 ',' y0 ',' x1 ',' y1
  30.     xg=minima(x0,x1); xd=maxima(x0,x1)
  31.     yh=minima(y0,y1); yb=maxima(y0,y1)
  32.     l=xd-xg+1; h=yb-yh+1
  33.     'NEXTSEL('obj')'; obj=result
  34.     end
  35. end
  36. else obj=1
  37.  
  38. if obj>0 then do
  39.     if fr=1 then 'GETZONE("Dessinez un rectangle avec la souris")'
  40.     else 'GETZONE("Draw a box with the mouse")'
  41.     coords=result
  42.     if coords="" then call quitter
  43.     PARSE VAR coords x0 ',' y0 ',' x1 ',' y1
  44.     xg=minima(x0,x1); xd=maxima(x0,x1)
  45.     yh=minima(y0,y1); yb=maxima(y0,y1)
  46.     l=xd-xg+1; h=yb-yh+1
  47. end
  48.  
  49. if fr=1 then 'ASKNUM("Axe horizontal"+CHR(10)+"Nombre de décades?",1)'
  50. else 'ASKNUM("Horizontal axis"+CHR(10)+"Number of decades?",1)'
  51. ndh = result
  52. if ndh<=0 then call quitter
  53. if fr=1 then 'SELECT("Type d''échelle"+CHR(10)+"1- Linéaire"+CHR(10)+"2- Logarithmique"+CHR(10)+"3- Antilogarithmique")'
  54. else 'SELECT("Scale type"+CHR(10)+"1- Linear"+CHR(10)+"2- Logarithmic"+CHR(10)+"3- Antilog")'
  55. tt=result
  56. x0=xg; y0=yh; y1=yh+h; x1=xg+ndh*(l%ndh)    /* Version 1.02 */
  57.  
  58. 'SAVEALL'
  59. if clip>=0 then 'MENU("Cut")'
  60. /* Tracé des lignes verticales */
  61. select
  62.     when tt=1 then do
  63.     /* Tracé des lignes verticales */
  64.     do i=1 to ndh
  65.         x2 = (x0)+i*(l/ndh)
  66.         x2 = x2%1
  67.         'DRAWMODE(-1)'
  68.         do c=1 to 9
  69.         xc = x2-(l/ndh)/10*c
  70.         xc=xc%1
  71.         'DRAW('xc','y0','xc','y1')'
  72.         end
  73.         'DRAWMODE(-2):DRAW('x2','y1','x2','y0')'
  74.     end
  75.     end
  76.     when tt=2 then do
  77.     if ~show('L','rexxmathlib.library') then
  78.        call addlib('rexxmathlib.library',0,-30)
  79.     /* Tracé des lignes verticales */
  80.     x2=x0
  81.     do i=1 to ndh
  82.         'DRAWMODE(-1)'
  83.         do c=2 to 9
  84.         xc=(l/ndh)*log10(c)
  85.         xc=(x2+xc)%1
  86.         'DRAW('xc','y0','xc','y1')'
  87.         end
  88.         x2 = (x0)+i*(l/ndh)
  89.         x2 = x2%1
  90.         'DRAWMODE(-2):DRAW('x2','y1','x2','y0')'
  91.     end
  92.     end
  93.     when tt=3 then do
  94.     if ~show('L','rexxmathlib.library') then
  95.        call addlib('rexxmathlib.library',0,-30)
  96.     x2=x1
  97.     do i=1 to ndh
  98.         'DRAWMODE(-2):DRAW('x2','y1','x2','y0')'
  99.         'DRAWMODE(-1)'
  100.         do c=2 to 9
  101.         xc=(l/ndh)*log10(c)
  102.         xc=(x2-xc)%1
  103.         'DRAW('xc','y0','xc','y1')'
  104.         end
  105.         x2 = (x1)-i*(l/ndh)
  106.         x2 = x2%1
  107.     end
  108.     end
  109.     otherwise call quitter
  110. end
  111.  
  112. if fr=1 then 'ASKNUM("Axe vertical"+CHR(10)+"Nombre de décades?",1)'
  113. else 'ASKNUM("Vertical axis"+CHR(10)+"Number of decades?",1)'
  114. ndv = result
  115. if ndv<=0 then call quitter
  116.  
  117. y1=y0+h
  118. x1=x0+ndh*(l%ndh)
  119. /* Tracé du contour */
  120. 'DRAWMODE(-2):DRAW('x0','y0','x1','y0'):DRAW('x0','y1','x0','y0')'
  121.  
  122. if fr=1 then 'SELECT("Type d''échelle"+CHR(10)+"1- Linéaire"+CHR(10)+"2- Logarithmique"+CHR(10)+"3- Antilogarithmique")'
  123. else 'SELECT("Scale type"+CHR(10)+"1- Linear"+CHR(10)+"2- Logarithmic"+CHR(10)+"3- Antilog")'
  124. tt=result
  125.  
  126. /* Tracé des lignes horizontales */
  127. select
  128.     when tt=1 then do
  129.     do i=1 to ndv
  130.         y2 = (y0)+i*(h/ndv)
  131.         y2 = y2%1
  132.         'DRAWMODE(-1)'
  133.         do c=1 to 9
  134.         yc = y2-(h/ndv)/10*c
  135.         yc=yc%1
  136.         'DRAW('x0','yc','x1','yc')'
  137.         end
  138.         'DRAWMODE(-2):DRAW('x0','y2','x1','y2')'
  139.     end
  140.     end
  141.     when tt=2 then do
  142.     if ~show('L','rexxmathlib.library') then
  143.        call addlib('rexxmathlib.library',0,-30)
  144.     y2=y1
  145.     do i=1 to ndv
  146.         'DRAWMODE(-2):DRAW('x0','y2','x1','y2')'
  147.         'DRAWMODE(-1)'
  148.         do c=2 to 9
  149.         yc=(h/ndv)*log10(c)
  150.         yc=(y2-yc)%1
  151.         'DRAW('x0','yc','x1','yc')'
  152.         end
  153.         y2 = y1-i*(h/ndv)
  154.         y2 = y2%1
  155.     end
  156.     end
  157.     when tt=3 then do
  158.     if ~show('L','rexxmathlib.library') then
  159.        call addlib('rexxmathlib.library',0,-30)
  160.  
  161.     y2=y0
  162.  
  163.     do i=1 to ndv
  164.         'DRAWMODE(-1)'
  165.         do c=2 to 9
  166.         yc=(h/ndv)*log10(c)
  167.         yc=(y2+yc)%1
  168.         'DRAW('x0','yc','x1','yc')'
  169.         end
  170.         y2 = (y0)+i*(h/ndv)
  171.         y2 = y2%1
  172.         'DRAWMODE(-2):DRAW('x0','y2','x1','y2')'
  173.     end
  174.     end
  175.     otherwise call quitter
  176. end
  177. call quitter
  178.  
  179. minima: procedure
  180.     parse arg v1,v2
  181.     if v1<v2 then return v1
  182.     return v2
  183. end
  184.  
  185. maxima: procedure
  186.     parse arg v1,v2
  187.     if v1>v2 then return v1
  188.     return v2
  189. end
  190.  
  191. quitter: procedure expose clip
  192.     if clip>=0 then 'CLIPUNIT('clip')'
  193.     exit
  194.  
  195. /* Traitement des erreurs, interruption du programme */
  196. syntax:
  197. erreur=RC
  198. if fr=1 then 'MESSAGE("Script grille.AmiCAD"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  199. else 'MESSAGE("Grille.AmiCAD Script"+CHR(10)+"Syntax error"+CHR(10)+"in line 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  200. call quitter
  201.  
  202. error:
  203. if fr=1 then 'MESSAGE("Script grille.AmiCAD"+CHR(10)+"Erreur en ligne 'SIGL'")'
  204. else 'MESSAGE("Grille.AmiCAD Script"+CHR(10)+"Error in line 'SIGL'")'
  205. call quitter
  206.